package com.example.fitnessservice.api.config;

import com.example.fitnessservice.module.pojo.Result;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

/**
 * @author feng
 * @version 1.0
 * @&#064;description: 异常驱动
 * @&#064;date 2022/11/28 8:50
 */
//@RestControllerAdvice
public class ExceptionConfig {
    @ExceptionHandler
    public Result doException(Exception e){
        Result result = new Result();
        result.setCode(500);
        if (e instanceof RuntimeException) {
            result.setMsg(e.getMessage());
        }
        return result;
    }
}
